package com.hiof.utility;

/**
 * Created by IntelliJ IDEA.
 * User: manish
 * Date: 3/26/12
 * Time: 10:48 AM
 * To change this template use File | Settings | File Templates.
 */

import android.location.Location;
import com.google.android.maps.GeoPoint;
import com.hiof.Configuration;

import java.util.ArrayList;
public class LocationUtils {
    public static final int DEFAULT_LATITUDE = 11351780;
    public static final int DEFAULT_LONGITUDE = 59129082;

    //default points for the coldspots for testing
    public static ArrayList<GeoPoint> getColdSpotsTrollstigenPoints() {
        ArrayList<GeoPoint> coldSpotsMolde = new ArrayList<GeoPoint>();
        coldSpotsMolde.add(new GeoPoint(62560879, 7684690));
        coldSpotsMolde.add(new GeoPoint(62540699, 7722280));
        coldSpotsMolde.add(new GeoPoint(62483501, 7668510));
        coldSpotsMolde.add(new GeoPoint(62459332, 7670890));
        coldSpotsMolde.add(new GeoPoint(62481403, 7728710));
        return coldSpotsMolde;
    }

    public static ArrayList<GeoPoint> getParkingLocationTrollstigenPoints() {
        ArrayList<GeoPoint> parkingLocationsTrollstigen = new ArrayList<GeoPoint>();
        parkingLocationsTrollstigen.add(new GeoPoint(62567551, 7687140));
        parkingLocationsTrollstigen.add(new GeoPoint(62557411, 7692660));
        parkingLocationsTrollstigen.add(new GeoPoint(62537701, 7729050));
        parkingLocationsTrollstigen.add(new GeoPoint(62484100, 7668910));
        parkingLocationsTrollstigen.add(new GeoPoint(62458260, 7672670));
        parkingLocationsTrollstigen.add(new GeoPoint(62460152, 7666370));
        return parkingLocationsTrollstigen;
    }

    public static GeoPoint getGeopointFromLocation(Location location) {
        return (location == null) ? new GeoPoint(DEFAULT_LATITUDE, DEFAULT_LONGITUDE)
                : new GeoPoint((int) (location.getLatitude() * 1e6), (int) (location.getLongitude() * 1e6));
    }

    public static double calculateDistanceFromLatLon(double oldLat, double oldLon, double lat, double lon) {
        float results[] = new float[3];
        Location.distanceBetween(oldLat, oldLon, lat, lon, results);
        return (double) results[0];
    }

    public static GeoPoint getGoogleGeoPointsFromLocalGeoPoint(com.hiof.servercommunication.receive.beans.GeoPoint geopoint){
        return new GeoPoint(geopoint.getLatE6(), geopoint.getLngE6());
    }
}
